package com.zzyl.nursing.controller;

import com.zzyl.common.annotation.Log;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.common.enums.BusinessType;
import com.zzyl.common.utils.poi.ExcelUtil;
import com.zzyl.nursing.domain.DeviceData;
import com.zzyl.nursing.dto.DeviceDataPageReqDto;
import com.zzyl.nursing.service.IDeviceDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * devicedateController
 *
 * @author LiuLi
 * @date 2025-08-23
 */
@Api(tags = "devicedate管理")
@RestController
@RequestMapping("/nursing/data")
public class DeviceDataController extends BaseController {
    @Autowired
    private IDeviceDataService deviceDataService;

    /**
     * 查询devicedate列表
     */
    @ApiOperation("查询devicedate列表")
    @PreAuthorize("@ss.hasPermi('nursing:date:list')")
    @GetMapping("/list")
    public TableDataInfo pageQuery(@ApiParam("devicedate查询条件") DeviceDataPageReqDto deviceDataPageReqDto) {
        return deviceDataService.pageQuery(deviceDataPageReqDto);
    }

    /**
     * 导出设备数据列表
     */
    @ApiOperation("导出设备数据列表")
    @PreAuthorize("@ss.hasPermi('nursing:deviceData:export')")
    @Log(title = "设备数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceData deviceData) {
        List<DeviceData> list = deviceDataService.selectDeviceDataList(deviceData);
        ExcelUtil<DeviceData> util = new ExcelUtil<DeviceData>(DeviceData.class);
        util.exportExcel(response, list, "设备数据数据");
    }

    /**
     * 获取devicedate详细信息
     */
    @ApiOperation("获取devicedate详细信息")
    @PreAuthorize("@ss.hasPermi('nursing:date:query')")
    @GetMapping(value = "/{id}")
    public R<DeviceData> getInfo(@ApiParam("devicedateID") @PathVariable("id") Long id) {
        return R.ok(deviceDataService.selectDeviceDataById(id));
    }

    /**
     * 新增devicedate
     */
    @ApiOperation("新增devicedate")
    @PreAuthorize("@ss.hasPermi('nursing:date:add')")
    @Log(title = "devicedate", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@ApiParam("devicedate信息") @RequestBody DeviceData deviceData) {
        return toAjax(deviceDataService.insertDeviceData(deviceData));
    }

    /**
     * 修改devicedate
     */
    @ApiOperation("修改devicedate")
    @PreAuthorize("@ss.hasPermi('nursing:date:edit')")
    @Log(title = "devicedate", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@ApiParam("devicedate信息") @RequestBody DeviceData deviceData) {
        return toAjax(deviceDataService.updateDeviceData(deviceData));
    }

    /**
     * 删除devicedate
     */
    @ApiOperation("删除devicedate")
    @PreAuthorize("@ss.hasPermi('nursing:date:remove')")
    @Log(title = "devicedate", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@ApiParam("devicedateID数组") @PathVariable Long[] ids) {
        return toAjax(deviceDataService.deleteDeviceDataByIds(ids));
    }
}
